Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

EventBusSubscriber improvements #82

Merged
merged 3 commits into from
Oct 12, 2024
Merged

EventBusSubscriber improvements #82

merged 3 commits into from
Oct 12, 2024

Conversation

Lyfts
Copy link
Member

@Lyfts Lyfts commented Oct 12, 2024

Invoking the @EventBusSubscriber.Condition method suffered from the same reflection problems as described in #80, which is that it will have to load the entire method table including parameters classes that might not be present.

Having to dynamically invoke a given method without reflection only leaves a few options, which are either using MethodHandle which are generally faster than reflection if invoked a ton of times but significantly slower if only invoked once
or using the semi-obscure LambdaMetafactory api. This generates a synthetic anonymous class that implements a functional interface to get a value from the specified method, while that might sound like it would be a lot slower than reflection it was in fact consistently faster and doesn't have to load the entire method table.

Makes @EventBusSubscriber's able to be registered during earlier init phases as some events are fired during pre-init, specifically some of the registry events. This means that if an @EventBusSubscriber wants to listen to that event and potentially pick up something that gets fired during the pre-init phase of a mod that loads earlier than NHLib, it would have to be registered during the construction phase. This is only applicable in very few cases but I thought it'd be best to at least make it an option.

Also some different minor improvements like using ASMDataTable.getAll to get the side-only classes instead of ASMDataTable.getAnnotationsFor. This alone lowered the time it took for that part of the pre-proccesing from ~90ms to ~5-15ms on my GT5U test branch, and that was while only ever using ASMDataTable.getAnnotationsFor twice...

@Lyfts Lyfts requested a review from a team October 12, 2024 11:21
@Lyfts Lyfts merged commit 28786c5 into master Oct 12, 2024
1 check passed
@Lyfts Lyfts deleted the event-bus-improvements branch October 12, 2024 17:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants